How to write a ColecoVision cartridge ROM game

The steps are: make a memory map, learn the OS calls, plan the scheduling,
write the main routine, write game logic, create overlays with graphics
and music for that overlay.  With experience these can be done in order,
but for novices, it is easier to do a little of each as the game is
developed.

Main memory

0000-1fff OS7 ROM (8k)
7000-73ff RAM area
7000      ColecoVision cartridge ram area
7020-702a Sound data areas
702b      User RAM (total of 962 bytes including stack)
73b9      Top of stack (grows downwards)
73ba-73c2 Pascal entry parameter passing area
73c3-73ff Display, Joystick, Timer areas
8000-8bff Main: Vectors, game start, graphics (3k)


Video memory

MODE_1 command does:
0000 Pattern generator table
1800 Pattern name table
1b00 Sprite attribute table
2000 Pattern color table
3800 Sprite generator table

Important Library calls

Set Video Mode (HGR/TEXT)
Set Interrupt Handler (NMIHANDLER)
Start Background Music (BGPLAY)
Sound effect (PLAYEFFECT)
Reading the joysticks (READJOYSTICK)
Debouncing the joysticks (JOY())

Important OS7 calls

GAME_OPTIONS	- Display the standard game options screen
MODE_1		- Set the display to graphics mode 1
LOAD_ASCII	- Load the ASCII character set font into the VDP

INIT_TABLE	- Initialize the VDP table location (color, pattern, sprite...)
GET_VRAM	- Read entries from the VRAM table into Z80 RAM
PUT_VRAM	- Write entries to the VRAM table from Z80 memory
WR_SPR_NM_TBL	- Write the sprite name table

WRITE_REGISTER	- Set a VDP register
READ_REGISTER	- Read the VDP status
WRITE_VRAM	- Write Z80 RAM to VRAM
READ_VRAM	- Read VRAM into Z80 RAM buffer
FILL_VRAM	- Fill VRAM with data

PUT_FRAME	- Place a rectangular character based object on the screen
GET_BKGRND	- Backup a character based rectangular object from the screen

POLLER		- Selective check the joystick for instructions

INIT_TIMER	- Initialize the timers
SET_SIGANAL	- Set a timer in the timer table
TEST_SIGNAL	- Test a timer to see if it has gone off
TIMER_MAN	- Timer manager (called during VDP interrrupts)

SOUND_INIT	- Initialize the sounds table
PLAY_IT		- Start a sound track
SOUND_MAN	- Sound manager (called during VDP interrupts)
ALL_SOUNDS_OFF	- Silence

RAND_GEN	- Pretty good random number generator


Game header

----------------------------------------------------------------------
	ORG	8000h

; Tables
	DB	055h,0aah	;Magic number
	DW	SPRITE_NAME	;Pointer to sprite name table
	DW	SPRITE_ORDER	;Pointer to sprite order table
	DW	SPRITE_WORKING	;Pointer to WR_SPR_NM_TBL work area
	DW	CONTROLLER_BUFFER	;Pointer to hand controler input area
	DW	MAIN_PROG	;Entry point to game
; Vectors
	JP	RST08		;Restart 8
	JP	RST10		;Restart 10h
	JP	RST18		;Restart 18h
	JP	RST20		;Restart 20h
	JP	RST28		;Restart 28h
	JP	RST30		;Restart 30h
	JP	MASK_INT	;Maskable interrupt (used by spinner)
	JP	VDPINT		;NMI interrupt (used by VDP 60 times per second)
; Title screen name
	DB	'ADAMCON 11',1eh,1fh
	DB	'/PRESENTS ADAM NEWS NETWORK'S'/1999'
	;1dh is copyright symbol
	;1eh,1fh is trade mark symbol

; Implementation of restart vectors
RST08
RST10
RST18
RST20
RST28
RST30
	RET

MASK_INT
	RETI	;Used with spinner: steering wheel, 
		;super action, roller controller
VDPINT
	RETN	;Non maskable interrupt used for:
		;background music, processing timers, defered VDP write
		;sprite order processing

;Main program entry
;Entry: B device number of the boot device
	
;Here is where the application begins
	CALL	GAME_OPT
;Endless loop
	JP	$

	END
-----------------------------------------------------------------------


